export interface IScriptRank {
  score: number
  goodRating: number
  dailyInstalls: number
  totalInstalls: number
  dailyAvgInstalls: number
  lastUpdatedDays: number
  createDays: number
  isMine: boolean
}

export interface IStats {
  maxDailyInstalls: number
  maxTotalInstalls: number
  maxGoodRatings: number
  maxDailyAvgInstalls: number
}

export const SCRIPT_TAG_LABELS = {
  highQuality: {
    value: 'high-quality',
    label: '高质量',
    bgColor: 'linear-gradient(135deg, #2E7D32, #4CAF50)',
  },
  popular: {
    value: 'popular',
    label: '热门',
    bgColor: 'linear-gradient(135deg, #FF5722, #FF9800)',
  },
  frequentlyUpdated: {
    value: 'frequently-updated',
    label: '近期更新',
    bgColor: 'linear-gradient(135deg, #2196F3, #03A9F4)',
  },
  recommended: {
    value: 'recommended',
    label: '推荐',
    bgColor: 'linear-gradient(135deg, #9C27B0, #E91E63)',
  },
  new: {
    value: 'new',
    label: '新上架',
    bgColor: 'linear-gradient(135deg, #607D8B, #9E9E9E)',
  },
  dailyInstallTop: {
    value: 'daily-install-top',
    label: '日安装量第一',
    bgColor: 'linear-gradient(135deg, #FF9800, #FFC107)',
  },
  totalInstallTop: {
    value: 'total-install-top',
    label: '总安装量第一',
    bgColor: 'linear-gradient(135deg, #9C27B0, #673AB7)',
  },
  goodRatingTop: {
    value: 'good-rating-top',
    label: '好评数第一',
    bgColor: 'linear-gradient(135deg, #4CAF50, #8BC34A)',
  },
  dailyAvgInstallTop: {
    value: 'daily-avg-install-top',
    label: '日均安装量第一',
    bgColor: 'linear-gradient(135deg, #00BCD4, #03A9F4)',
  },
  mine: {
    value: 'mine',
    label: '我的',
    bgColor: 'linear-gradient(135deg, #FF4081, #F50057)',
  },
}

/**
 * 生成所有标签的CSS样式
 */
export function generateScriptTagStyles(): string {
  return Object.values(SCRIPT_TAG_LABELS)
    .map(tag => `
.script-tag.${tag.value} {
  background: ${tag.bgColor} !important;
}`)
    .join('\n')
}

// 标签互斥
export const TAG_EXCLUSIVE_RULES: {
  primary: string
  excluded: string[]
}[] = [
  { primary: SCRIPT_TAG_LABELS.new.value, excluded: [SCRIPT_TAG_LABELS.frequentlyUpdated.value] },
]

// 评分等级配置
export const SCORE_LEVELS = {
  high: { min: 80, color: '#4CAF50', label: '高分' },
  medium: { min: 60, color: '#FFC107', label: '中分' },
  low: { min: 0, color: '#F44336', label: '低分' },
}

export type ScoreLevelType = keyof typeof SCORE_LEVELS

// 标签最低分配置
export const TAG_MIN_SCORES = {
  default: 60, // 有任意标签的最低分
  popular: 80, // 热门标签最低分
  highQuality: 85, // 高质量标签最低分
}

export enum ScriptDataMarkerType {
  MarkerTypes = 'data-user-types',
  MarkerLiker = 'data-script-liker',
  MarkerSuccess = 'data-script-success',
}

export enum FeedbackDataMarkerType {
  MarkerTypes = 'data-user-types',
  MarkerTags = 'data-feedback-tags',
  MarkerStatus = 'data-feedback-status',
}
